package org.jeecg.modules.iot.aio.task;

import org.jeecg.modules.iot.aio.ChannelContext;
import org.jeecg.modules.iot.aio.task.base.AbstractQueueRunnable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.core.TcpConst;
import org.tio.utils.queue.FullWaitQueue;
import org.tio.utils.queue.TioFullWaitQueue;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * 这里是一个注释
 *
 * @author scw
 * @version v1.0
 * @date
 */
public class SendMessageRunnable extends AbstractQueueRunnable<String> {

    private static final Logger log	 = LoggerFactory.getLogger(SendMessageRunnable.class);

    /** The msg queue. */
    private FullWaitQueue<String> msgQueue = null;
    private ChannelContext channelContext = null;
    public boolean canSend = true;

    private static final int	MAX_CAPACITY_MIN	= TcpConst.MAX_DATA_LENGTH - 1024;	//减掉1024是尽量防止溢出的一小部分还分成一个tcp包发出
    private static final int	MAX_CAPACITY_MAX	= MAX_CAPACITY_MIN * 10;

    public SendMessageRunnable(ThreadPoolExecutor executor) {
        super(executor);
    }

    @Override
    public void runTask() {
        if (msgQueue.isEmpty())return;


    }




    @Override
    public FullWaitQueue<String> getMsgQueue() {
        if (msgQueue == null) {
            synchronized (this) {
                if (msgQueue == null) {
                    msgQueue = new TioFullWaitQueue<String>(Integer.getInteger("tio.fullqueue.capacity", null), false);
                }
            }
        }
        return msgQueue;
    }

}
